<?php
/** .-------------------------------------------------------------------
 * |  Software: [HDCMS framework]
 * |      Site: www.hdcms.com
 * |-------------------------------------------------------------------
 * |    Author: 向军 <2300071698@qq.com>
 * |    WeChat: aihoudun
 * | Copyright (c) 2012-2019, www.houdunwang.com. All Rights Reserved.
 * '-------------------------------------------------------------------*/

namespace web\home\controller;


class Common{
	
	public function __construct(){
		//获取webset里面数据
		//参考手册查询构造器lists
		$webSetData = Db::table('webset')->lists('name,value');
		View::with('webSetData',$webSetData);
//		p($webSetData);
		//获取公共头部分类信息
		$headCateData = Db::table('category')
			->where('pid',0)
			->orderBy('cid','desc')
			->limit(3)
			->get();
//		p($headCateData);
		View::with('headCateData',$headCateData);
//		右侧所有分类
		$allCateData = Db::table('category')->get();
//		p($allCateData);
		foreach ($allCateData as $k=>$v){
			$allCateData[$k]['total'] = Db::table('article')
				->where('category_cid',$v['cid'])->count();
		}
//		p($allCateData);
		View::with('allCateData',$allCateData);
		//标签云
		$tagData = Db::table('tag')->get();
		View::with('tagData',$tagData);

		//最新文章
		$articleDate = Db::table('article')->limit(3)->orderBy('sendtime','desc')->get();
		View::with('articleDate',$articleDate);
		//友情链接
		$linkData = Db::table('link')->get();
		View::with('linkData',$linkData);



	}
}
